#ifndef DPLGRAPHICVIEW_H
#define DPLGRAPHICVIEW_H

#include <QGraphicsView>
#include <QRect>
#include <QRectF>

class QGraphicsScene;
class GraphicsViewBase;
class DplDrawScan ;
class QTimer      ;
class DplGraphicView : public QGraphicsView
{
    Q_OBJECT
public:
    enum OVERLAY
    {
        OVERLAY_NONE = 0 ,
        OVERLAY_GATE = 1 ,
        OVERLAY_GRID = 2 ,
        OVERLAY_WIELD = 4 ,
        OVERLAY_ALL  = 0xFF
    };

    explicit DplGraphicView(QWidget *parent = 0 , QSize size = QSize(800 , 600));
    ~DplGraphicView();


    void   SetDrawOperation(DplDrawScan* pDrawScan_);
    void   SetupMatrixScale(double nScaleH_ , double nScaleV_);
    void   EnableRenderOpenGL(bool bEnable_ = true) ;
    void   SetBackgroundBrush(const QColor& color)  ;
    void   EnableOverLay(OVERLAY nOverLay_ = DplGraphicView::OVERLAY_NONE) ;
    void   SetSceneRange(QRectF& range) ;

protected:
    void   wheelEvent ( QWheelEvent * event ) ;
    void   resizeEvent(QResizeEvent *event) ;
    void   mousePressEvent(QMouseEvent *event);
    void   mouseReleaseEvent(QMouseEvent *event);
    void   InitGraphicView(const QSize& cSize_);
    void   zoomAction() ;
    void   CreateOverlayItems() ;
    void   GeometryChanged() ;
    QRectF RangeTranslate(QRectF& rect_) ;
private:
    QGraphicsScene*   m_pScene        ;
    GraphicsViewBase* m_pBackGround   ;
    DplDrawScan*      m_pDrawScan     ;

    double            m_nScaleH       ;
    double            m_nScaleV       ;
    QRectF            m_cRange        ;
    QRect             m_cZoomRect     ;
    QPoint            m_cPosStart     ;
    QPoint            m_cPosStop      ;
    OVERLAY           m_eOverlayType  ;
    QTimer* timer ;
signals:
    void signalViewChanged(QRectF rect)  ;
public slots:
    void slotResetView();
    void slotPrint();
    void slotTimeOut();
private slots:

};

#endif // DPLGRAPHICVIEW_H
